<?php
/***
 * 描述：供应商管理[管理员权限]
 * @category		Admin		
 * @package			Action			
 * @subpackage			
 * @author			wanght <whtaok@gmail.com>
 * @since			2013-4-6
 * @version			$Id: SupplyerManageAction.class.php 3 2013-10-14 02:49:41Z whtaok@gmail.com $
 */
class SupplyerManageAction extends AdminAction {
	/**
	 * 供应商管理首页面
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function indexAct() {
		$search = array(
				'title'=>I('title'),
			);
		$mod=new ShopSupplyerModel();
		$mod->setModWhere($search);
		$list = $mod->select();
		$this->assign('list',$list);
		$this->assign('search',$search);
		$this->display('index');
	}
	
	/**
	 * 显示添加页面
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function showAddAct() {
		$this->display('add');
	}
	
	/**
	 * 添加操作
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function doAddAct() {
		$mod=new ShopSupplyerModel();
		if(!$mod->create()){
			$this->error($mod->getError());
		}
		$mod->add();
		$this->success('添加成功', U('index'));
	}
	
	/**
	 * 显示编辑页面
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function showUpdAct($id) {
		$mod=new ShopSupplyerModel();
		$detail = $mod->find($id);
		$this->assign("detail",$detail);
		$this->display('upd');
	}
	
	/**
	 * 编辑操作
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function doUpdAct($id) {
		$mod=new ShopSupplyerModel();
		if(!$mod->create()){
			$this->error($mod->getError());
		}
		$mod->save();
		$this->success('保存成功', U('index'));
	}
	
	/**
	 * 删除操作
	 * @access		public
	 * @author		wanght<whtaok@gmail.com>
	 * @since		2013-3-3
	 */
	public function doDelAct($id) {
		$mod = new ShopSupplyerModel();
		$mod->idForWhere($id);
		$mod->setField('is_valid','4');
		$this->success('删除成功', U('index'));
	}
	
	public function showDialogAct(){
		$search = array(
			'title'=>I('title'),
			'content'=>I('content'),
			'product_code'=>I('product_code'),
		);
		//设置查询条件
		$modWhere = array(
			'title'=>$search['title'],
			'content'=>$search['content'],
			'product_code'=>$search['product_code'],
		);
		$mod=new ShopSupplyerModel();
		$totalRows = $mod->setModWhere($modWhere)->count();
		list($list,$page) = $mod->setModWhere($modWhere)->listPage($totalRows);
		$this->assign('list',$list);
		$this->assign('page',$page);
		$this->assign('search',$search);
		exit($this->fetch('dialog_search'));
	}

}

?>